{% load i18n grp_tags %}
<style>
    header#grp-header #grp-navigation ul#grp-user-tools > li.grp-user-options-container {
        width: auto;
    }
    #grp-user-tools {
        width: auto;
    }
    .view_student{
        padding: 0px 1px 0px 1px;
        margin: 0px;
    }
    div.view_student{
         width:12.8%;
         float:left;
    }
    input.view_student{
        margin-top: 6px;
    }
    header#grp-header #grp-navigation ul#grp-user-tools > li a {
        padding-left: 5px;
        padding-right: 5px;
    }
</style>

<div id="grp-navigation">
    <h1 id="grp-admin-title">{% if grappelli_admin_title %}{{ grappelli_admin_title }}{% else %}{% get_admin_title %}{% endif %}</h1>
    
    <!-- View Student -->
    {% if perms.sis.change_student or perms.sis.view_student %}
        <div class="admin-title noprint view_student" style="height:30px;">
            <form id="form_view_student" class="view_student" action="/sis/view_student/" method="post">
                {% csrf_token %}
                <input type="text" style="width:100%;" placeholder="Lookup Student" name="view_student_text" id="id_view_student_text" value="" maxlength="255" class="ui-autocomplete-input view_student" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">
                
                <input type="hidden" name="student" id="id_view_student" value="">
                <div id="id_view_student_on_deck" style="visibility: hidden;" class="results_on_deck"><div></div></div>
                <script type="text/javascript">//<![CDATA[
                jQuery(document).ready(function($){
                        addAutoComplete("id_view_student", function(html_id) {
                                $("#"+html_id).autocompleteselect({
                                        minLength: 1,
                                        source: '/ajax_select/ajax_lookup/dstudent',
                                });
                        });
                $("#id_view_student_on_deck").bind('added',function() {
                    $('#form_view_student').submit()
                });
                });//]]>
                </script>
                <style type="text/css">@import url("/static/ajax_select/css/ajax_select.css");</style><script type="text/javascript" src="/static/ajax_select/js/ajax_select.js"></script>
            </form>
        </div>
    {% endif %}
    
    {% if user.is_authenticated and user.is_staff %}
        <ul id="grp-user-tools">
            
            <!-- Student -->
            {% if perms.sis.change_student or perms.sis.view_student or perms.sis.reports %}
                <li class="grp-user-options-container grp-collapse grp-closed">
                    <a href="javascript://" class="user-options-handler grp-collapse-handler"> Student </a>
                    <ul class="grp-user-options">
                        {% if perms.sis.view_student %}
                            <li><a href="{% url ecwsp.sis.views.photo_flash_card %}">{% trans 'Flashcards' %}</a></li>
                        {% endif %}
                        {% if perms.sis.change_student or perms.sis.view_student %}
                            <li><a href="{% url admin:sis_student_changelist %}">{% trans 'Edit' %}</a></li>
                        {% endif %}
                        {% if perms.sis.reports %}
                            <li><a href="{% url ecwsp.sis.views.school_report_builder_view %}">{% trans 'Reports' %}</a></li>
                        {% endif %}
                    </ul>
                </li>
            {% endif %}
            
            <!-- Attendance  -->
            {% if 'ecwsp.attendance' in settings.INSTALLED_APPS %}
            {% if perms.sis.reports or perms.attendance.change_studentattendance or perms.attendance.take_studentattendance %}
                <li class="grp-user-options-container grp-collapse grp-closed">
                    <a href="javascript://" class="user-options-handler grp-collapse-handler"> {% trans 'Attendance' %} </a>
                    <ul class="grp-user-options">
                        {% if perms.attendance.take_studentattendance %}
                            <li><a href="{% url ecwsp.attendance.views.teacher_attendance %}">{% trans 'Take Homeroom Attendance' %}</a>
                        {% endif %}
                        {% if perms.attendance.change_studentattendance %}
                            <li><a href="{% url admin:attendance_studentattendance_changelist %}">{% trans 'Edit' %}</a></li>
                        {% endif %}
                        {% if perms.studentattendance.reports %}
                            <li><a href="{% url ecwsp.attendance.views.attendance_report %}">{% trans 'Reports' %}</a></li>
                        {% endif %}
                    </ul>
                </li>
            {% endif %}
            {% endif %}
            
            <!-- Discipline  -->
            {% if 'ecwsp.discipline' in settings.INSTALLED_APPS %}
            {% if perms.discipline.change_studentdiscipline %}
                <li class="grp-user-options-container grp-collapse grp-closed">
                    <a href="javascript://" class="user-options-handler grp-collapse-handler"> {% trans 'Discipline' %} </a>
                    <ul class="grp-user-options">
                        {% if perms.discipline.change_studentdiscipline %}
                            <li><a href="{% url ecwsp.discipline.views.view_discipline %}">{% trans 'View' %}</a>
                        {% endif %}
                        {% if perms.discipline.change_studentdiscipline %}
                            <li><a href="{% url admin:discipline_studentdiscipline_changelist %}">{% trans 'Edit' %}</a></li>
                        {% endif %}
                        {% if perms.sis.reports %}
                            <li><a href="{% url ecwsp.discipline.views.discipline_report_view %}">{% trans 'Reports' %}</a></li>
                        {% endif %}
                    </ul>
                </li>
            {% endif %}
            {% endif %}
        
            <!-- Grades  -->
            {% if 'ecwsp.schedule' in settings.INSTALLED_APPS %} {% if perms.schedule.change_course or perms.grades.change_own_grade or perms.sis.reports %}
                <li class="grp-user-options-container grp-collapse grp-closed">
                    <a href="javascript://" class="user-options-handler grp-collapse-handler"> Grades </a>
                    <ul class="grp-user-options">
                        {% if perms.schedule.change_course %}
                            <li><a href="{% url admin:schedule_course_changelist %}">{% trans 'Edit Grades/Courses' %}</a></li>
                        {% endif %}
                        {% if perms.grades.change_own_grade and 'ecwsp.grades' in settings.INSTALLED_APPS %}
                            <li><a href="{% url ecwsp.grades.views.teacher_grade %}">{% trans 'Submit Grades' %}</a>
                        {% endif %}
                        {% if perms.sis.reports %}
                            <li><a href="{% url ecwsp.sis.views.grade_report %}">{% trans 'Reports' %}</a></li>
                            <li><a href="{% url ecwsp.schedule.views.grade_analytics %}">{% trans 'Analytics' %}</a></li>
                        {% endif %}
                        {% if 'ecwsp.engrade_sync' in settings.INSTALLED_APPS %} {% if perms.engrade_sync.change_coursesync %}
                            <li><a href="{% url ecwsp.engrade_sync.views.setup %}">{% trans 'Engrade Setup' %}</a></li>
                        {% endif %}{% endif %}
                    </ul>
                </li>
            {% endif %}{% endif %}
    
            <!-- Admissions  -->
            {% if perms.admissions.change_applicant and 'ecwsp.admissions' in settings.INSTALLED_APPS %}
                <li class="grp-user-options-container grp-collapse grp-closed">
                    <a href="javascript://" class="user-options-handler grp-collapse-handler"> Admissions </a>
                    <ul class="grp-user-options">
                        {% if perms.admissions.change_applicant %}
                            <li><a href="{% url admin:admissions_applicant_changelist %}">{% trans 'Applicants' %}</a></li>
                        {% endif %}
                        {% if perms.admissions.change_applicant %}
                            <li><a href="{% url ecwsp.admissions.views.reports %}">{% trans 'Reports' %}</a></li>
                        {% endif %}
                    </ul>
                </li>
            {% endif %}
            
            <!-- Alumni -->
            {% if perms.alumni.change_alumni and 'ecwsp.alumni' in settings.INSTALLED_APPS %}
                <li class="grp-user-options-container grp-collapse grp-closed">
                    <a href="javascript://" class="user-options-handler grp-collapse-handler"> Alumni </a>
                    <ul class="grp-user-options">
                        <li><a href="{% url admin:app_list 'alumni'%}">{% trans 'Alumni Admin' %}</a></li>
                        <li><a href="{% url admin:alumni_alumni_changelist %}">{% trans 'Alumnus' %}</a></li>
                    </ul>
                </li>
            {% endif %}
            
            <!-- Counseling -->
            {% if perms.counseling.add_referralform and 'ecwsp.counseling' in settings.INSTALLED_APPS %}
                <li class="grp-user-options-container grp-collapse grp-closed">
                    <a href="javascript://" class="user-options-handler grp-collapse-handler"> Counseling </a>
                    <ul class="grp-user-options">
                        {% if perms.counseling.change_studentmeeting %}
                            <li><a href="{% url admin:app_list 'counseling'%}">{% trans 'Counseling Admin' %}</a></li>
                        {% endif %}
                        <li><a href="{% url admin:counseling_referralform_add %}">{% trans 'Submit Referral Form' %}</a></li>
                    </ul>
                </li>
            {% endif %}
            
            <!-- CWSP -->
            {% if 'ecwsp.work_study' in settings.INSTALLED_APPS %} {% if perms.work_study.change_studentworker or perms.work_study.view_studentworker or perm.work_study.reports %}
                <li class="grp-user-options-container grp-collapse grp-closed">
                    <a href="javascript://" class="user-options-handler grp-collapse-handler"> CWSP </a>
                    <ul class="grp-user-options">
                        {% if perms.work_study.change_studentworker or perms.work_study.view_studentworker %}
                            <li><a href="{% url admin:work_study_studentworker_changelist %}">{% trans 'Edit Student Worker' %}</a></li>
                        {% endif %}
                        {% if perms.sis.reports %}
                            <li><a href="{% url ecwsp.work_study.views.report_builder_view %}">{% trans 'Reports' %}</a></li>
                        {% endif %}
                        {% if perms.sis.reports and settings.CRND_ROUTES %}
                            <li><a href="{% url ecwsp.work_study.views.routes %}">{% trans 'Route Reports' %}</a></li>
                        {% endif %}
                    </ul>
                </li>
            {% endif %}{% endif %}
    
            <!-- OMR -->
            {% if 'ecwsp.omr' in settings.INSTALLED_APPS %} {% if perms.omr.change_test or perms.omr.teacher_test %}
                <li class="grp-user-options-container grp-collapse grp-closed">
                    <a href="javascript://" class="user-options-handler grp-collapse-handler"> OMR </a>
                    <ul class="grp-user-options">
                        {% if perms.omr.change_test %}
                            <li><a href="{% url admin:app_list 'omr'%}">{% trans 'OMR Admin' %}</a></li>
                        {% endif %}
                        {% if perms.omr.teacher_test %}
                            <li><a href="{% url ecwsp.omr.views.my_tests %}"> {% trans 'My Tests' %}</a></li>
                        {% endif %}
                    </ul>
                </li>
            {% endif %}{% endif %}
    
            <!-- Administration -->
            {% if perms.sis.reports or perms.administration.change_configuration or perms.custom_field.change_custom_field %}
                <li class="grp-user-options-container grp-collapse grp-closed">
                    <a href="javascript://" class="user-options-handler grp-collapse-handler"> Admin </a>
                    <ul class="grp-user-options">
                        {% if perms.sis.reports %}
                            <li><a href="{% url ecwsp.sis.views.import_everything %}">{% trans 'School import' %}</a></li>
                        {% endif %}
                        {% if perms.administration.change_configuration %}
                            <li><a href="{% url admin:administration_configuration_changelist %}">{% trans 'Configuration' %}</a></li>
                        {% endif %}
                        {% if perms.custom_field.change_custom_field %}
                            <li><a href="{% url admin:custom_field_customfield_changelist %}">{% trans 'Custom Fields' %}</a></li>
                        {% endif %}
                        {% if 'ecwsp.canvas_sync' in settings.INSTALLED_APPS and perms.sis.reports %}
                            <li><a href="{% url ecwsp.canvas_sync.views.setup %}">{% trans 'Canvas Sync' %}</a></li>
                        {% endif %}
                    </ul>
                </li>
            {% endif %}
            
            <!-- Username -->
            <li class="grp-user-options-container grp-collapse grp-closed">
                <a style="min-width:72px;" href="javascript://" class="user-options-handler grp-collapse-handler">{% firstof user.first_name user.username %}</a>
                <ul class="grp-user-options">
                    <!--SWORD: added preferences -->
                    <li><a href="/sis/preferences">{% trans 'Preferences' %}</a>
                    <!-- Change Password -->
                    {% url admin:password_change as password_change_url %}
                    {% if password_change_url %}
                        <li><a href="{{ password_change_url }}">
                    {% else %}
                        <li><a href="{{ root_path }}password_change/">
                    {% endif %}
                    {% trans 'Change password' %}</a></li>
                    <!-- Logout -->
                    {% url admin:logout as logout_url %}
                    {% if logout_url %}
                        <li><a href="{{ logout_url }}">
                    {% else %}
                        <li><a href="{{ root_path }}logout/">
                    {% endif %}
                    {% trans 'Log out' %}</a></li>
                </ul>
            </li>
            <!-- Userlinks -->
            {% block userlinks %}
                <!-- JS tests -->
                {% url test-index as testindexurl %}
                {% if testindexurl %}
                    <li><a href="{{ testindexurl }}">{% trans 'Tests' %}</a></li>
                {% endif %}
            {% endblock %}
        </ul>
    {% endif %}
    {% block nav-global %}
    {% endblock %}
</div>

<script type="text/javascript" charset="utf-8">
    (function($) {
        $(document).ready(function() {
            $("#grp-navigation .grp-collapse").grp_collapsible();
        });
    })(django.jQuery);
</script>






